{echo:JS::import('dialog?skin=simple');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<!--S 产品展示-->
<link type="text/css" rel="stylesheet" href="{url:#css/product.css}" />
<script type='text/javascript' src="{url:#js/jquery.enlarge.js}"></script>
<script type="text/javascript">
	//$("body").addClass("screen_960");
</script>
<div class="nav-bar mt5 clearfix">
    {list:items=$category_nav}
    <a class="category-{$key}" href="{url:/index/category/cid/$item[id]}">{$item['name']} {if:$item!=end($category_nav)}&gt;{/if}</a>
    {/list}
</div>
<div id="product-intro" class="clearfix mt10" style="position: relative;">
	<ul class="product-info">
        <li class="product-title"><h1>{$goods['name']}</h1></li>
        <li class="clearfix"><p class="fl"><label>{lang:MARKET_PRICE}：</label><s id="market-price">{$currency_symbol}{$goods['market_price']}</s></p><p class="fr"><label>{lang:PRODUCT_NO}：</label><span id="pro-no">{$goods['goods_no']}</span></p></li>

        <li >
        <ul class=" prom">
        {if:!empty($prom)}
        {if:isset($user['group_id'])}
                {set:$group_id = ','.$user['group_id'].',';}
            {/if}
        <li class="product-price"><label>{lang:PROMOTION_PRICE}：</label><span id="prom_price" class="price" formula="{$prom['parse']['minus']}">{$currency_symbol} {$prom['parse']['real_price']}</span><em class="promo-type">
        {$prom['name']}{if:$prom['parse']['note']!=''}【{$prom['parse']['note']}】{/if} <i class="icon-clock ie6png"></i>{lang:ENDED}：<span id="countdown1"  style="color:#333; "></span></em>

                    <script type="text/javascript">
                    $("#countdown1").countdown({end_time:"{echo:date('Y/m/d H:i:s',strtotime($prom['end_time']))}"});
                    </script>
        {if:isset($group_id)}
                {if:stripos(','.$prom['group'].',',$group_id)===false}
                    {lang:MEMBER_LEVEL_NOT_ENOUGH_MSG}
                {/if}
            {else:}
                {lang:LOGIN_GET_ACTIVITY_MSG}
            {/if}
        </li>
        <li><label></label><span>{lang:SELL_PRICE}&nbsp;&nbsp;</span><s id="sell_price"> {$currency_symbol}{$goods['sell_price']}</s></li>
        {else:}
        <li class="product-price"><label>{lang:SELL_PRICE}：</label><span></span><span id="sell_price" class="price">{$currency_symbol}{$goods['sell_price']}</span></li>
        {/if}
        {if:$goods['store_nums']>0}
        <li class="clearfix"><label></label><span>{lang:INVENTORY}&nbsp;&nbsp;</span><span id="goods_nums">({$goods['store_nums']})</span></li>
        {else:}
        <li class="clearfix"><label><b class="f16">{lang:NO_INVENTORY_MSG}</b></label><span>{lang:GOODS_NO_INVENTORY}</span>  <span class="btn btn-gray btn-mini" id="goods-notify">{lang:NOTICE_OF_ARRIVAL}</span></li>
        {/if}
        </ul>
        </li>
        <li class="clearfix" style="height:24px; line-height:24px;"><label class="fl">{lang:GOODS_COMMENTS}：</label><span class="score fl ie6png"><i style="width:{$comment['a']['percent']}%"></i></span><span>[ {lang:ALL_PEOPLE}({$comment['total']}){lang:PEOPLE_HAVE_COMMENTS} ]</span></li>

    </ul>
    <div class="spec-info mt10">
        {list:items=unserialize($goods['specs']) item=$spec}
        <dl class="spec-item clearfix">
            <dt>{$spec['name']}：</dt>
            <dd>
                <ul class="spec-values" spec_id="{$spec['id']}">
                {list:items=$spec['value'] item=$value}
                <li data-value="{$spec['id']}:{$value['id']}">{if:$value['img']==''}<span>{$value['name']}</span>{else:}<img src="{echo:Common::thumb($value['img'],100)}"  width="36" height="36"><label>{$value['name']}</label>{/if}<i></i></li>
                {/list}
                </ul>
            </dd>
        </dl>
        {/list}
        <dl class="spec-item clearfix">
            <dt>{lang:BUY_NUMBER}：</dt>
            <dd class="buy-num" id="buy-num-bar"><a href="javascript:;">-</a><input id="buy-num" name="buy_num" value="1"  maxlength=5><a href="javascript:;">+</a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="vm">{lang:CAN_BUY_NUMBER}：<b id="store_nums" class="red">{$goods['store_nums']}</b></span></dd>
        </dl>
        <dl id="spec-msg" class="spec-item clearfix" style="display: none;">
            <dt></dt>
            <dd ><p class="msg"><i class="icon icon-alert"></i><span >{lang:SELECT_SIZE_PLEASE}</span></p>
            </dd>
        </dl>
        <dl class="spec-item clearfix">
            <dt></dt>
            <dd>
                <a href="javascript:;" id="add-cart" class="btn" style="padding:6px 20px;"><i class="icon-cart ie6png"></i> {lang:ADD_TO_CART}</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:;" id="attention" class="btn btn-gray"><i class="icon-plus-1 ie6png"></i>{lang:CONCERN}</a>
            </dd>
        </dl>
    </div>
	<div id="preview" >
	<div id="imgmini" style="width: 367px;height:367px;border: 1px #ccc solid;"><img class="big-pic" width="367"  src="{echo:Common::thumb($goods['img'],367)}" source="{url:@$goods[img]}"></div>
	   <div id="gallery">
        <a class="turn-left ie6png"></a>
        <div class="show-list">
        <div style="position: absolute;width:800px;">
    		{list:items=unserialize($goods['imgs']) item=$img}
            <a class="small-img" href="javascript:;"><img src="{echo:Common::thumb($img,367)}"  source="{url:@$img}"></a>
    		{/list}
        </div>
        </div>
        <a class="turn-right ie6png"></a>
	</div>
</div>
</div>
<!--S 商品详情-->
<div class="goods-detail clearfix">
    <div class="sidebar">
        <div class="box">
            <h2>{lang:SIMILAR_PRODUCTS}</h2>
            <ul class="content child-category-list ">
                {set:$path_like = "like '$goods[path]%'";}
                {query:name=goods where= is_online eq 0 and category_id in (select id from tiny_goods_category where path $path_like) order=sort desc limit=10}
                {if:$goods['id']!=$item['id']}
                <li>
                    <dl>
                        <dt class="img tc"><a href="{url:/index/product/id/$item[id]}"><img src="{echo:Common::thumb($item['img'],220,220)}" width=220></a></dt>
                        <dd><a href="{url:/index/product/id/$item[id]}">{$item['name']}</a></dd>
                        <dd><span class="price">{lang:sell_price}：<b class="red">{$currency_symbol}{$item['sell_price']}</b></span><span class="market_price fr">{lang:market_price}：<s>{$currency_symbol}{$item['market_price']}</s></span></dd>
                    </dl>
                </li>
                {/if}
                {/list}
            </ul>
        </div>
    </div>
    <div class="content" style="margin-left: 12px;">
        <!--S 捆绑销售 -->
        {query:name=bundling where=CONCAT(',',goods_id,',') like '%,$goods[id],%' and status eq 1 items=$bundling/}
        {if:$bundling}
        <div class="tab ">
        <h1 class="f18">{lang:COMBINATION_PRODUCTS}：</h1>
                <ul class="tab-head">
                {list:items=$bundling}
                    <li>{lang:SUIT}{echo:($key+1)}</li>
                {/list}
                </ul>
                <div class="tab-body bundling-list " style="min-height: 180px;">
                    {list:items=$bundling item=$bun}
                    {set:$gids = $goods['id'].','.$bun['goods_id'];$total_price=0.00;}
                    <div class="group-item">
                        {query:name=goods where=id in($gids) order=field(`id`,$gids)}
                        {set:$total_price+=$item['sell_price'];}
                        <div class="goods-item">
                            {if:$key!=0}<s class="icon-add ie6png"></s>{/if}
                            <div><a href="{url:/index/product/id/$item[id]}"><img src="{echo:Common::thumb($item['img'],100,100)}"  width="100" height="100"></a></div>
                            <div style="overflow:hidden;height:36px;">{$item['name']}</div>
                        </div>
                        {/query}
                        <div class="goods-item" style="width:200px;padding-left:20px">
                            <s class="icon-equal"></s>
                            <div class="title"><b>{$bun['title']}</b></div>
                            <div>{lang:COMBINATION_PRICE}： {$currency_symbol}{$bun['price']}</div>
                            <div>{lang:ORIGINAL_PRICE}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;： <del>{$currency_symbol}{$total_price}</del></div>
                            <div>{lang:SAVE_PRICE}： {$currency_symbol}{echo:$total_price-$bun['price']}</div>
                            <div class="mt10"><a href="{url:/index/bundbuy/id/$bun[id]}" class="btn btn-mini">{lang:BUY_NOW}</a></div>
                        </div>
                    </div>
                    {/list}
                </div>
        </div>
        {/if}
        <!--S 捆绑销售 -->
        <div class="tab clearfix">
            <ul class="tab-head">
                <li>{lang:PRODUCT_DETAIL}</li>
                <li>{lang:GOODS_COMMENTS}</li>
                <li>{lang:GOODS_QUESTION}</li>
                <li>{lang:GOODS_SERVICE}</li>
            </ul>
            <div class="tab-body" style="min-height: 200px;">
                <!--S 商品详情-->
                <div class="p10 clearfix">
                    <div class="">
                        <ul class="attr-list ">
                            <li>{lang:GOODS_NAME}：{$goods['name']}</li>
                            <li>{lang:GOODS_NO}：{$goods['pro_no']}</li>
                            <li>{lang:GOODS_WEIGHT}：{$goods['weight']}g</li>
                            <li>{lang:GOODS_SALE_TIME}：{$goods['create_time']}</li>
                            {list:items=$goods_attrs}
                            <li>{$item['name']}：{$item['vname']}</li>
                            {/list}
                        </ul>
                    </div>
                    <div class="description  clearfix" >
                    {$goods['content']}
                    </div>
                </div>
                <!--E 商品详情-->
                <!--S 商品评价-->
                <div style="padding: 20px;" class="comment-list">
                    <div class="comment-top clearfix">
                        <ul>
                            <li>
                                <div class="tc comment-score"><em class="tc circle ">{$comment['a']['percent']}<i style="font-size: 18px;">%</i></em>- {lang:GOODS_GOOD_COMMENTS} -</div>
                                <div class="mt10 score ie6png"><i style="width:{$comment['a']['percent']}%"></i></div>
                            </li>
                            <li class="comment-grade">
                                <div>
                                    <h1>{lang:ALL_PEOPLE}({$comment['total']}){lang:PEOPLE_HAVE_COMMENTS}</h1>
                                    <dl class="comment-percent">
                                        <dt>3 {lang:GOODS_STAR}</dt>
                                        <dd class="bar"><i style="width:{$comment['a']['percent']}%"></i></dd>
                                        <dd class="percent">{$comment['a']['percent']}%</dd>
                                        <dt>2 {lang:GOODS_STAR}</dt>
                                        <dd class="bar"><i style="width:{$comment['b']['percent']}%"></i></dd>
                                        <dd class="percent">{$comment['b']['percent']}%</dd>
                                        <dt>1 {lang:GOODS_STAR}</dt>
                                        <dd class="bar"><i style="width:{$comment['c']['percent']}%"></i></dd>
                                        <dd class="percent">{$comment['c']['percent']}%</dd>
                                    </dl>
                                </div>
                            </li>
                            <li class="comment-action">
                                <div>
                                    {set:$uid = isset($user['id'])?$user['id']:0;}
                                    {query:name=review where=goods_id eq $id and user_id eq $uid and status eq 0 limit=1 /}
                                    {if:$items}
                                    {list:}
                                    <a href="{url:/index/review/id/$item[id]}" class="btn">{lang:GOODS_WANT_COMMENT}</a>
                                    {/list}
                                    {else:}
                                    <a href="javascript:;" class="btn btn-disable">{lang:GOODS_WANT_COMMENT}</a>
                                    {/if}
                                    <p>{lang:GOODS_COMMENTS_TIPS}</p>

                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="comment tab" id="comment">
                        <ul class="tab-head">
                            <li>{lang:ALL_COMMENT}({$comment['total']})</li>
                            <li>3 {lang:GOODS_STAR}({$comment['a']['num']})</li>
                            <li>2 {lang:GOODS_STAR}({$comment['b']['num']})</li>
                            <li>1 {lang:GOODS_STAR}({$comment['c']['num']})</li>
                        </ul>
                        <div class="tab-body">
                            <div id="comment-all" class="js-template">
                                <div class="page-nav"></div>
                                <div class="page-content">
                                    <div class="comment-item">
                                        <div class="consult-q">
                                            <div class="head">
                                                <img src="{head_pic}" width="80" height="80">
                                                <strong cla>{uname}</strong>
                                                <i class="arrow"><b></b></i>
                                            </div>
                                            <div class="comment-content">
                                                <p class="top"><span class="score "><i style="width:{point}%"></i></span><span class="fr">{comment_time|今天}</span></p>
                                                <p >{content}</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="page-nav"></div>
                            </div>

                            <div id="comment-a" class="js-template">
                                <div class="page-nav"></div>
                                <div class="page-content">
                                    <div class="comment-item">
                                        <div class="consult-q">
                                            <div class="head">
                                                <img src="{head_pic}" width="80" height="80">
                                                <strong>{uname}</strong>
                                                <i class="arrow"><b></b></i>
                                            </div>
                                            <div class="comment-content">
                                                <p class="top"><span class="score "><i style="width:{point}%"></i></span><span class="fr">{comment_time|今天}</span></p>
                                                <p >{content}</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="page-nav"></div>
                            </div>

                            <div id="comment-b" class="js-template">
                                <div class="page-nav"></div>
                                <div class="page-content">
                                    <div class="comment-item">
                                        <div class="consult-q">
                                            <div class="head">
                                                <img src="{head_pic}" width="80" height="80">
                                                <strong>{uname}</strong>
                                                <i class="arrow"><b></b></i>
                                            </div>
                                            <div class="comment-content">
                                                <p class="top"><span class="score "><i style="width:{point}%"></i></span><span class="fr">{comment_time|今天}</span></p>
                                                <p >{content}</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="page-nav"></div>
                            </div>

                            <div id="comment-c" class="js-template">
                                <div class="page-nav"></div>
                                <div class="page-content">
                                    <div class="comment-item">
                                        <div class="consult-q">
                                            <div class="head">
                                                <img src="{head_pic}" width="80" height="80">
                                                <strong>{uname}</strong>
                                                <i class="arrow"><b></b></i>
                                            </div>
                                            <div class="comment-content">
                                                <p class="top"><span class="score "><i style="width:{point}%"></i></span><span class="fr">{comment_time|今天}</span></p>
                                                <p >{content}</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="page-nav"></div>
                            </div>
                        </div>

                    </div>
                </div>
                <!--E 商品评价-->
                <!--S 商品咨询-->
                <div class="consult clearfix" >
                    <form  style="overflow:hidden;width:100%">
                    <div class="box" style="margin:20px;">
                        <h2>{lang:GOODS_QUESTION}：</h2>
                        <div class="p15">
                            <div class="txt-panel mb5">
                                <textarea name="content" id="consult-content"  class="p5 "></textarea>
                            </div>
                            <div class="clearfix"><span class="fl"><input type="text" class="input" name="verifyCode" id="verifyCode" style="width: 80px;" ><img id="captcha_img"  src="{url:/simple/captcha/h/40/w/120}"><label><a href="javascript:void(0)" class="red" onclick="document.getElementById('captcha_img').src='{url:/simple/captcha/h/40/w/120/random/}'+Math.random()" id="change-img">{lang:CHANGE_ONE}</a></label></span>
                            <span class="fr">
                                <input type="submit" id="consult" value="{lang:GOODS_QUESTION_COMMIT}" class="btn"> <input type="reset" value="{lang:CANCLE}" class="btn btn-gray">
                            </span></div>
                        </div>

                    </div>
                    </form>
                    <div id="goods-consult" class="js-template">
                    <div class="page-nav"></div>
                    <div  class="page-content" id="page-content">
                    <div class="consult-item">
                        <div class="consult-q">
                            <div class="head">
                                <img  src="{head_pic}" style="width:80px;height:80px;">
                                <strong>{uname|网友}</strong>
                                <i class="arrow"><b></b></i>
                            </div>
                            <div class="consult-content">{question}
                                <p class="tr">{ask_time}</p>
                            </div>
                        </div>
                        <div class="consult-a {content||hidden}" >
                            <div class="head">
                                <img src="{url:#images/no-img.png}" width="80" height="80">
                                <strong>{lang:MALL_SERVICE}</strong>
                                <i class="arrow"><b></b></i>
                            </div>
                            <div class="consult-content">{content}
                                <p class="tl">{reply_time|今天}</p>
                            </div>
                        </div>
                    </div>
                    </div>
                    <div class="page-nav"></div>
                    </div>
                </div>
                <!--E 商品咨询-->
                <!--S 售后保障-->
                <div class="clearfix p20">
                    {if:$goods['sale_protection']}
                    <div class="mb20">
                        {$goods['sale_protection']}
                    </div>
                    {/if}
                    <div >
                        {$sale_protection}
                    </div>
                </div>
                <!--E 售后保障-->
            </div>
        </div>
    </div>
</div>
<!--E 商品详情-->
<div  id="notify-dialog" class="hidden">
<form id="notify_form"  method="post"  callback="submit_notify">
<h1>{lang:NOTIFICATION_OF_ARRIVAL}：</h1>
    <table class="form" style="width:400px;">
        <tr>
            <td class="label"><b class="red">*</b> {lang:email}：</td>
            <td> <input type="text" id="n_email" name="email" pattern="email" ></td>
        </tr>
        <tr>
            <td class="label">{lang:PHONE_NUMBER}：</td>
            <td><input type="text" id="n_mobile" empty name="mobile"   pattern="mobi"></td>
        </tr>
        <tr>
            <td colspan="2" class="tc"><input type="submit" class="btn" value="到货通知"></td>
        </tr>
    </table>
    </form>
</div>
<script type="text/javascript">
$("#goods-consult").Paging({
                url:'{url:/index/get_ask}',
                params:{id:{$goods['id']}}
            });
$("#comment-all").Paging({
                url:'{url:/index/get_review}',
                params:{id:{$goods['id']}}
            });
$("#comment-a").Paging({
                url:'{url:/index/get_review}',
                params:{id:{$goods['id']},score:'a'}
            });
$("#comment-b").Paging({
                url:'{url:/index/get_review}',
                params:{id:{$goods['id']},score:'b'}
            });
$("#comment-c").Paging({
                url:'{url:/index/get_review}',
                params:{id:{$goods['id']},score:'c'}
            });

$("#consult").on("click",function(){
    var content = $("#consult-content").val();
    var verifyCode = $("#verifyCode").val();
    if(!Tiny.user.online)art.dialog.alert('{lang:NEED_LOGIN_FOR_ASK}');
    else if(content=='')art.dialog.alert("{lang:CONTENT_NOT_EMPTY}");
    else if(verifyCode=='')art.dialog.alert("{lang:VERIFY_NOT_EMPTY}");
    else{
        $.post("{url:/index/goods_consult}",{id:'{$goods['id']}',content:content,verifyCode:verifyCode},function(data){
                if(data['status']=='success'){
                    $("#goods-consult").Paging({
                    url:'{url:/index/get_ask}',
                    params:{id:{$goods['id']}}
                });
                    $("#consult-content").val('');
                    $("#verifyCode").val('');
                    FireEvent(document.getElementById('change-img'),"click");
                    art.dialog.tips("<p class='success'>{lang:PUBLISH_SUECCEEDED}</p>");
            }else{
                art.dialog.alert("<p class='fail'>"+data['msg']+"</p>");
            }
        },'json')
    }

    return false;
})

	$("#imgmini").enlarge({
        // 鼠标遮罩层样式
        shadecolor: "#FFF",
        shadeborder: "#FF8000",
        shadeopacity: 0.5,
        cursor: "move",

        // 大图外层样式
        layerwidth: 367,
        layerheight: 367,
        layerborder: "#DDD",
        fade: true});
    var skuMap = {echo:JSON::encode($skumap)};
    //更新库存信息
    var store_nums = 0;
    for(i in skuMap){
        store_nums += parseInt(skuMap[i]['store_nums']);
    }
    $("#store_nums").text(store_nums);
    $("#goods_nums").text(store_nums);

    $("#gallery  .small-img").each(function(i){
        if(i==0)$(this).addClass("current");
    	$(this).on("mouseenter",function(){
            $(this).parent().find("a").removeClass("current");
            $(this).addClass("current");
            $("#imgmini img").attr("src",$(this).find("img").attr("src"));
            $("#imgmini img").attr("source",$(this).find("img").attr("source"));
    	})
    });
    $(".spec-values li").each(function(){
        $(this).on("click",function(){
            var disabled = $(this).hasClass('disabled');
            if(disabled) return;
            var flage = $(this).hasClass('selected');

            $(this).parent().find("li").removeClass("selected");
            if(!flage){
                $(this).addClass("selected");
            }
            changeStatus();
             if($(".spec-values").length == $(".spec-values .selected").length){
                var sku = new Array();
                $(".spec-values .selected").each(function(i){
                    sku[i]= $(this).attr("data-value");
                })
                var sku_key = ";"+sku.join(";")+";";
                if(skuMap[sku_key]!=undefined){
                    var sku = skuMap[sku_key];
                    $("#sell_price").text("{$currency_symbol}"+sku['sell_price']);
                    $("#store_nums").text(sku['store_nums']);
                    $("#goods_nums").text(sku['store_nums']);
                    if($("#prom_price").size()>0){
                        var formula = $("#prom_price").attr('formula');
                        var prom_price = eval(sku['sell_price']+formula);
                        if(prom_price<=0)prom_price = 0;
                        $("#prom_price").text("{$currency_symbol} "+prom_price.toFixed(2));
                    }

                    $("#market-price").text(sku['market_price']);
                    $("#pro-no").text(sku['pro_no']);
                }
                $("#spec-msg").css("display","none");
             }else{
                $("#store_nums").text("{$goods['store_nums']}");
                $("#goods_nums").text("{$goods['store_nums']}");
             }
        })
    })
    function changeStatus(){
        var specs_array = new Array();
        $(".spec-values").each(function(i){
            var selected = $(this).find(".selected");
            if(selected.length>0)specs_array[i]=selected.attr("data-value");
            else specs_array[i] = "\\\d+:\\\d+";
        });
        $(".spec-values").each(function(i){
            var selected = $(this).find(".selected");
            $(this).find("li").removeClass("disabled");
            var k = i;
            $(this).find("li").each(function(){

                var temp = specs_array.slice();
                temp[k] = $(this).attr('data-value');
                var flage = false;
                for(sku in skuMap){
                    var reg = new RegExp(';'+temp.join(";")+';');
                    if(reg.test(sku) && skuMap[sku]['store_nums']>0) flage = true;
                }
                if(!flage)$(this).addClass("disabled");
            })

        });
    }
    $("#buy-num-bar a:eq(0)").on("click",function(){
        var num = $("#buy-num-bar input").val();
        if(num>1) num--;
        else num=1;
        $("#buy-num-bar input").val(num);
    });
    $("#buy-num-bar a:eq(1)").on("click",function(){
        var num = $("#buy-num-bar input").val();
        var max = parseInt($("#store_nums").text());
        if(num<max) num++;
        else num=max;
        $("#buy-num-bar input").val(num);
    });
    $("#buy-num-bar input").on("change",function(){
        var value = $(this).val();
        var max = parseInt($("#store_nums").text());
        if((/^\d+$/i).test(value)){
            value = Math.abs(parseInt(value));
            if(value<1) value = 1;
            if(value>max) value = max;
        }else{
            value = 1;
        }
        $(this).val(value);
    })
    $("#buy-now").on("click",function(){
        if($(".spec-values").length == $(".spec-values .selected").length){

            $(".spec-values .selected").each(function(){

            })

        }else{
            $("#spec-msg").css("display","");
        }
    })
    //添加到购物车
    $("#add-cart").on("click",function(){
        var product = currentProduct();
        if(product){
            var id = product["id"];
            var num = parseInt($("#buy-num").val());
            var max = parseInt($("#store_nums").text());
            var cart_num = parseInt($("#"+id).find(".num").text());
            if((num+cart_num)>max){
                $("#spec-msg").css("display","");
                showMsgBar('stop',"{lang:TOO_MANY_PRODUCTS}");
                return false;
            }else if(max<=0){
                $("#spec-msg").css("display","");
                showMsgBar('stop',"{lang:NO_INVENTORY}");
                return false;
            }
            else{
                $("#spec-msg").css("display","none");
            }
            $.post("{url:/index/cart_add}",{id:id,num:num},function(data){
                updateCart(data);

                var tmp=$($("#imgmini img").get(0).cloneNode(true));
                tmp.css({position: 'absolute','z-index':'9998', border:'solid 1px #ccc', background:'#aaf','overflow':'hidden' ,background:'#fff'});
                var imgView=$("#imgmini").offset();
                tmp.css(imgView);
                tmp.appendTo($('body'));
                var end = $("#shopping-cart").offset();
                step1 = {top:end.top-160,left:end.left+100,width:100,height:100,opacity:0.8};
                step2 = {top:end.top,left:end.left+100,width:100,height:100,opacity:0};

                $(tmp).animate(step1,"slow",function(){$("#card-wrap").animate({top:-15}).animate({top:-5});}).animate(step2, "slow",function(){
                        tmp.remove();
                      });
            },"json");
        }else{
            $("#spec-msg").css("display","");
            showMsgBar('alert',"{lang:SELECT_SIZE_PLEASE}");
        }
    });

    //取得当前商品
    function currentProduct(){
        if($(".spec-values").length==0){
            return skuMap[''];
        }
        if($(".spec-values").length == $(".spec-values .selected").not(".disabled").length){
            var sku = new Array();
            $(".spec-values .selected").each(function(i){
                sku[i]= $(this).attr("data-value");
            })
            var sku_key = ";"+sku.join(";")+";";
            if(skuMap[sku_key]!=undefined){
                return skuMap[sku_key];
            }else return null;
         }
         else return null;
    }
    //展示信息
    function showMsgBar(type,text){
        $(".msg").find("span").text(text);
        $(".msg").find("i").attr("class","icon icon-"+type);
    }
    //切换画廊图片
    $(".turn-right,.turn-left").on("click",function(){
        var canvas = $(".show-list >div");
        var num = canvas.find("a").size();
        var flage = -1;
        var current = 0;
        var width = 66;
        var show_num = 5;
        var left = 0;
        current = Math.round((Math.abs(canvas.position().left)/width));
        if($(this).hasClass("turn-left")){
            current--;
        }else{
            current++;
        }
        if(num-current>=show_num && current>=0){
            left = current*flage*width;
            canvas.animate({left:left},200);
        }
    })

    $("#attention").on("click",function(){
        $.post("{url:/index/attention}",{goods_id:{$id}},function(data){
            if(data['status']==2) art.dialog.tips("<p class='warning'>{lang:HAS_CANCERNED}</p>");
            else if(data['status']==1) art.dialog.tips("<p class='success'>{lang:CANCERN_SUCCEEDED}</p>");
            else art.dialog.tips("<p class='warning'>{lang:PLEASE_LOGIN}</p>");
        },'json')
    })
    //到货通知
    $("#goods-notify").on("click",function(){
        if(Tiny['user']['online']){
            art.dialog({id:'notify-dialog',content:document.getElementById('notify-dialog')});
        }else{
            art.dialog.tips("<p class='warning'>{lang:PLEASE_LOGIN}</p>");
        }

    })
    function submit_notify(e)
    {
         if(e==null){
            var email = $("#n_email").val();
            var mobile = $("#n_mobile").val();
            $.post("{url:/index/notify}",{goods_id:{$goods['id']},email:email,mobile:mobile},function(data){
                if(data['status']!= undefined){
                    art.dialog({id:'notify-dialog'}).close();
                    art.dialog.tips('<p class="'+data['status']+'">'+data['msg']+'</p>');
                }
            },'json');
            return false;
        }
        return false;
    }
    </script>
<!--E 产品展示-->
